﻿using System;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Collections.Generic;

namespace DomusDotNet.Sbm.ObjectModel.DbModel
{
    public class CustomDatabaseInitializerStrategy<T> : IDatabaseInitializer<T> where T : Db
    {
        public void InitializeDatabase(T context)
        {
            ///Drop and Create database.
            if (context.Database.Exists()) context.Database.Delete();

            
            context.Database.Create();
            ////Create a simple Stored Procedure to count books in library.
            context.Database.ExecuteSqlCommand(@"CREATE PROCEDURE GetBooks @Title nvarchar(120) AS SELECT ID,ISBN,Title,Version,Volume,Available FROM Books WHERE Title Like '%' + @Title +'%'");

        }
    }
}
